package models

import (
	"gorm.io/gorm"
	"time"
	"user_srv/basic/config"
)

type Doctor struct {
	Id               uint           `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
	DoctorName       string         `gorm:"column:doctor_name;type:varchar(30);comment:医生姓名;not null;" json:"doctor_name"`             // 医生姓名
	DoctorUrl        string         `gorm:"column:doctor_url;type:varchar(255);comment:医生头像;not null;" json:"doctor_url"`              // 医生头像
	HospitalPosition string         `gorm:"column:hospital_position;type:varchar(50);comment:医院职位;not null;" json:"hospital_position"` // 医院职位
	HospitalType     string         `gorm:"column:hospital_type;type:varchar(50);comment:技术类别;not null;" json:"hospital_type"`         // 技术类别
	CreatedAt        time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt        time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt        gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (d *Doctor) TableName() string {
	return "doctor"
}
func (d *Doctor) CreateDoctor() error { //添加医生
	return config.DB.Create(&d).Error
}
func (d *Doctor) DetailDoctor() error { //医生详情
	return config.DB.Where("id = ?", d.Id).Limit(1).Find(&d).Error
}
